<template>
  <div class="home">
    <el-container>
      <el-header style="height: 80px">
        <el-row>
          <el-col :span="11">
            <div class="grid-content bg-purple">
              <i class="el-icon-s-fold"></i>
              <label>宿舍管理系统</label>
            </div>
          </el-col>
          <el-col :span="12" class="header-right">
            <div>
              <el-avatar :size="40" :src="circleUrl"></el-avatar>
              <span>{{ userName.a_name }} </span>
              <i class="el-icon-switch-button" @click="go_login"></i>
            </div>
          </el-col>
        </el-row>
      </el-header>
      <el-container class="el-container">
        <el-aside width="240px">
          <el-row class="tac">
            <el-col>
              <el-menu default-active="1" class="el-menu-vertical-demo" :router="true">
                <el-menu-item :key="v.href" v-for="v in power" :index="v.href">
                  <i :class="v.icon"></i>
                  <span slot="title">{{ v.title }}</span>
                </el-menu-item>
                <!-- 富文本编辑 -->
                <el-menu-item index="/home/edit">
                  <i class="el-icon-eleme"></i>
                  <span slot="title">富文本编辑</span>
                </el-menu-item>
                <!-- Highcharts -->
                 <el-menu-item index="/home/highCharts">
                  <i class="el-icon-eleme"></i>
                  <span slot="title">图表内容</span>
                </el-menu-item>
                <!-- Echarts -->
                <el-menu-item index="/home/eCharts">
                  <i class="el-icon-eleme"></i>
                  <span slot="title">eCharts图表内容</span>
                </el-menu-item>
                <!-- <el-menu-item index="1">
                  <i class="el-icon-eleme"></i>
                  <router-link to="/home/noticeHome">公告主页</router-link>
                </el-menu-item>
                <el-menu-item index="2">
                  <i class="el-icon-picture-outline-round"></i>
                  <router-link to="/home/dorm">宿舍管理</router-link>
                </el-menu-item>
                <el-menu-item index="3">
                  <i class="el-icon-help"></i>
                  <span slot="title">
                    <router-link to="/home/student">学生管理</router-link>
                  </span>
                </el-menu-item>
                <el-menu-item index="4">
                  <i class="el-icon-copy-document"></i>
                  <span slot="title">
                    <router-link to="/home/notice">公告管理</router-link>
                  </span>
                </el-menu-item>
                <el-menu-item index="5">
                  <i class="el-icon-user"></i>
                  <router-link to="/home/admin">管理员管理</router-link>
                </el-menu-item> -->
              </el-menu>
            </el-col>
          </el-row>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data: function () {
    return {
      circleUrl:
        "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png",
      sizeList: ["large", "medium", "small"],
      userName: "",
      power: [],
    };
  },
  methods: {
    go_login: function () {
      this.$router.push("/");
    },
  },
  mounted: function () {
    const user = sessionStorage.getItem("userName");
    // 获取列表信息
    const power = JSON.parse(sessionStorage.getItem("power"));
    if (user) {
      this.userName = JSON.parse(user);
    } else {
      this.$message.error("需要重新登了！");
      this.$router.push("/");
    }
    this.power = power;
  },
};
</script>

<style scoped lang="less">
.el-header {
  background-color: #4985fb;
  color: #fff;
  line-height: 80px;
  font-size: 20px;

  .el-icon-s-fold {
    font-size: 42px;
    vertical-align: middle;
  }
  label {
    font-size: 26px;
    vertical-align: middle;
  }
  .el-icon-rank {
    font-size: 25px;
    vertical-align: middle;
    margin-right: 10px;
  }
  .header-right {
    text-align: right;
  }
  .el-avatar {
    vertical-align: middle;
    line-height: 80px;
    margin-right: 10px;
  }
  span {
    vertical-align: middle;
  }
  .el-icon-switch-button {
    margin-left: 5px;
    vertical-align: middle;
    font-size: 24px;

    &:hover {
      color: red;
      cursor: pointer;
    }
  }
}

.el-aside {
  background-color: #fff;
  color: #333;
  text-align: left;
  li {
    padding-left: 30px;
  }
  a {
    text-decoration: none;
    list-style: none;
    font-size: 16px;
  }
  .el-menu {
    border: none;
  }
  .el-menu-item {
    padding: 0 30px;
  }
}

.el-main {
  background-color: #ffffff;
  color: #333;
}
.el-container {
  height: 100vh;
}
</style>

